package com.zushiye.order.controller;


import com.zushiye.order.model.response.CateListResponse;
import com.zushiye.order.model.response.HomeDataResponse;
import com.zushiye.order.service.JsonFileReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


@RestController
@RequestMapping("/home_data")
public class HomeController {

    @Autowired
    private JsonFileReadService service;

    //http://127.0.0.1:8080/home/get
    @GetMapping(value = "/get")
    public HomeDataResponse login() {
        try {
            HomeDataResponse res = service.readJsonFile("home_data.json", HomeDataResponse.class);
            return res;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return new HomeDataResponse();
    }


}
